{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Python绘制足球传递网络图"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "***网络图Graph***：\n",
    "* 由节点、边、权重所组成的数据关系图\n",
    "* 直观的展示事物节点间的复杂关系"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Graph, Page"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1. 读取足球赛队员传球数据集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>MatchID</th>\n",
       "      <th>TeamID</th>\n",
       "      <th>OriginPlayerID</th>\n",
       "      <th>DestinationPlayerID</th>\n",
       "      <th>MatchPeriod</th>\n",
       "      <th>EventTime</th>\n",
       "      <th>EventSubType</th>\n",
       "      <th>EventOrigin_x</th>\n",
       "      <th>EventOrigin_y</th>\n",
       "      <th>EventDestination_x</th>\n",
       "      <th>EventDestination_y</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>Huskies</td>\n",
       "      <td>Huskies_D1</td>\n",
       "      <td>Huskies_F1</td>\n",
       "      <td>1H</td>\n",
       "      <td>46.323501</td>\n",
       "      <td>Head pass</td>\n",
       "      <td>34</td>\n",
       "      <td>97</td>\n",
       "      <td>59.0</td>\n",
       "      <td>95.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>Huskies</td>\n",
       "      <td>Huskies_M1</td>\n",
       "      <td>Huskies_F2</td>\n",
       "      <td>1H</td>\n",
       "      <td>51.022546</td>\n",
       "      <td>Simple pass</td>\n",
       "      <td>53</td>\n",
       "      <td>89</td>\n",
       "      <td>69.0</td>\n",
       "      <td>91.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>Opponent1</td>\n",
       "      <td>Opponent1_D2</td>\n",
       "      <td>Opponent1_G1</td>\n",
       "      <td>1H</td>\n",
       "      <td>89.008721</td>\n",
       "      <td>Simple pass</td>\n",
       "      <td>19</td>\n",
       "      <td>16</td>\n",
       "      <td>5.0</td>\n",
       "      <td>50.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>Opponent1</td>\n",
       "      <td>Opponent1_G1</td>\n",
       "      <td>Opponent1_F1</td>\n",
       "      <td>1H</td>\n",
       "      <td>92.216160</td>\n",
       "      <td>Launch</td>\n",
       "      <td>5</td>\n",
       "      <td>50</td>\n",
       "      <td>67.0</td>\n",
       "      <td>44.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1</td>\n",
       "      <td>Huskies</td>\n",
       "      <td>Huskies_M2</td>\n",
       "      <td>Huskies_M3</td>\n",
       "      <td>1H</td>\n",
       "      <td>98.265191</td>\n",
       "      <td>Simple pass</td>\n",
       "      <td>42</td>\n",
       "      <td>55</td>\n",
       "      <td>36.0</td>\n",
       "      <td>54.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   MatchID     TeamID OriginPlayerID DestinationPlayerID MatchPeriod  \\\n",
       "0        1    Huskies     Huskies_D1          Huskies_F1          1H   \n",
       "1        1    Huskies     Huskies_M1          Huskies_F2          1H   \n",
       "2        1  Opponent1   Opponent1_D2        Opponent1_G1          1H   \n",
       "3        1  Opponent1   Opponent1_G1        Opponent1_F1          1H   \n",
       "4        1    Huskies     Huskies_M2          Huskies_M3          1H   \n",
       "\n",
       "   EventTime EventSubType  EventOrigin_x  EventOrigin_y  EventDestination_x  \\\n",
       "0  46.323501    Head pass             34             97                59.0   \n",
       "1  51.022546  Simple pass             53             89                69.0   \n",
       "2  89.008721  Simple pass             19             16                 5.0   \n",
       "3  92.216160       Launch              5             50                67.0   \n",
       "4  98.265191  Simple pass             42             55                36.0   \n",
       "\n",
       "   EventDestination_y  \n",
       "0                95.0  \n",
       "1                91.0  \n",
       "2                50.0  \n",
       "3                44.0  \n",
       "4                54.0  "
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dataset = pd.read_csv('./datas/passingevents.csv')\n",
    "dataset.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>MatchID</th>\n",
       "      <th>TeamID</th>\n",
       "      <th>OriginPlayerID</th>\n",
       "      <th>DestinationPlayerID</th>\n",
       "      <th>MatchPeriod</th>\n",
       "      <th>EventTime</th>\n",
       "      <th>EventSubType</th>\n",
       "      <th>EventOrigin_x</th>\n",
       "      <th>EventOrigin_y</th>\n",
       "      <th>EventDestination_x</th>\n",
       "      <th>EventDestination_y</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>Huskies</td>\n",
       "      <td>Huskies_D1</td>\n",
       "      <td>Huskies_F1</td>\n",
       "      <td>1H</td>\n",
       "      <td>46.323501</td>\n",
       "      <td>Head pass</td>\n",
       "      <td>34</td>\n",
       "      <td>97</td>\n",
       "      <td>59.0</td>\n",
       "      <td>95.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>Huskies</td>\n",
       "      <td>Huskies_M1</td>\n",
       "      <td>Huskies_F2</td>\n",
       "      <td>1H</td>\n",
       "      <td>51.022546</td>\n",
       "      <td>Simple pass</td>\n",
       "      <td>53</td>\n",
       "      <td>89</td>\n",
       "      <td>69.0</td>\n",
       "      <td>91.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1</td>\n",
       "      <td>Huskies</td>\n",
       "      <td>Huskies_M2</td>\n",
       "      <td>Huskies_M3</td>\n",
       "      <td>1H</td>\n",
       "      <td>98.265191</td>\n",
       "      <td>Simple pass</td>\n",
       "      <td>42</td>\n",
       "      <td>55</td>\n",
       "      <td>36.0</td>\n",
       "      <td>54.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>1</td>\n",
       "      <td>Huskies</td>\n",
       "      <td>Huskies_D1</td>\n",
       "      <td>Huskies_F1</td>\n",
       "      <td>1H</td>\n",
       "      <td>130.656530</td>\n",
       "      <td>Head pass</td>\n",
       "      <td>34</td>\n",
       "      <td>91</td>\n",
       "      <td>52.0</td>\n",
       "      <td>97.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>1</td>\n",
       "      <td>Huskies</td>\n",
       "      <td>Huskies_D1</td>\n",
       "      <td>Huskies_G1</td>\n",
       "      <td>1H</td>\n",
       "      <td>161.221470</td>\n",
       "      <td>Simple pass</td>\n",
       "      <td>14</td>\n",
       "      <td>65</td>\n",
       "      <td>11.0</td>\n",
       "      <td>50.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    MatchID   TeamID OriginPlayerID DestinationPlayerID MatchPeriod  \\\n",
       "0         1  Huskies     Huskies_D1          Huskies_F1          1H   \n",
       "1         1  Huskies     Huskies_M1          Huskies_F2          1H   \n",
       "4         1  Huskies     Huskies_M2          Huskies_M3          1H   \n",
       "8         1  Huskies     Huskies_D1          Huskies_F1          1H   \n",
       "11        1  Huskies     Huskies_D1          Huskies_G1          1H   \n",
       "\n",
       "     EventTime EventSubType  EventOrigin_x  EventOrigin_y  EventDestination_x  \\\n",
       "0    46.323501    Head pass             34             97                59.0   \n",
       "1    51.022546  Simple pass             53             89                69.0   \n",
       "4    98.265191  Simple pass             42             55                36.0   \n",
       "8   130.656530    Head pass             34             91                52.0   \n",
       "11  161.221470  Simple pass             14             65                11.0   \n",
       "\n",
       "    EventDestination_y  \n",
       "0                 95.0  \n",
       "1                 91.0  \n",
       "4                 54.0  \n",
       "8                 97.0  \n",
       "11                50.0  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 只取一个场次，一个队伍的数据\n",
    "dataset = dataset[(dataset[\"MatchID\"]==1) & (dataset[\"TeamID\"]=='Huskies')]\n",
    "dataset.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>OriginPlayerID</th>\n",
       "      <th>DestinationPlayerID</th>\n",
       "      <th>size</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Huskies_D1</td>\n",
       "      <td>Huskies_D2</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Huskies_D1</td>\n",
       "      <td>Huskies_D3</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Huskies_D1</td>\n",
       "      <td>Huskies_D4</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Huskies_D1</td>\n",
       "      <td>Huskies_D5</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Huskies_D1</td>\n",
       "      <td>Huskies_F1</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  OriginPlayerID DestinationPlayerID  size\n",
       "0     Huskies_D1          Huskies_D2    14\n",
       "1     Huskies_D1          Huskies_D3     8\n",
       "2     Huskies_D1          Huskies_D4     1\n",
       "3     Huskies_D1          Huskies_D5     3\n",
       "4     Huskies_D1          Huskies_F1     3"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 汇总计算，每个球员给其它球员传了多少次球\n",
    "dataset = dataset.groupby([\"OriginPlayerID\", \"DestinationPlayerID\"]).size().reset_index(name='size')\n",
    "dataset.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2. 构造Graph所需的nodes、links数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['Huskies_D1', 'Huskies_D2', 'Huskies_D3', 'Huskies_D4',\n",
       "       'Huskies_D5', 'Huskies_F1', 'Huskies_F2', 'Huskies_F3',\n",
       "       'Huskies_G1', 'Huskies_M1', 'Huskies_M2', 'Huskies_M3',\n",
       "       'Huskies_M4', 'Huskies_M5'], dtype=object)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 所有去重后的队员ID\n",
    "players = pd.concat([dataset[\"OriginPlayerID\"], dataset[\"DestinationPlayerID\"]]).unique()\n",
    "players"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'name': 'Huskies_D1', 'symbolSize': 10},\n",
       " {'name': 'Huskies_D2', 'symbolSize': 10},\n",
       " {'name': 'Huskies_D3', 'symbolSize': 10}]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 图所需的节点列表\n",
    "nodes = []\n",
    "for player in players:\n",
    "    nodes.append({\"name\": player, \"symbolSize\": 10})\n",
    "nodes[:3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'source': 'Huskies_D1', 'target': 'Huskies_D2', 'value': 14},\n",
       " {'source': 'Huskies_D1', 'target': 'Huskies_D3', 'value': 8},\n",
       " {'source': 'Huskies_D1', 'target': 'Huskies_D4', 'value': 1}]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 图所需要的边\n",
    "links=[]\n",
    "for index, row in dataset.iterrows():\n",
    "    links.append({\"source\": row[\"OriginPlayerID\"], \n",
    "                  \"target\": row[\"DestinationPlayerID\"], \n",
    "                  \"value\": row[\"size\"]})\n",
    "links[:3]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3. 使用Pyecharts绘制Graph图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "graph = (\n",
    "    Graph()\n",
    "    .add(\"\", \n",
    "        nodes,  # 节点列表\n",
    "        links,  # 边列表\n",
    "        repulsion=5000,   #节点之间的斥力因子，值越大则斥力越大\n",
    "        edge_label=opts.LabelOpts(is_show=True, position=\"middle\", formatter=\"{c}\"), # 在边上显示数据\n",
    "    )\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"传球网络图\"))\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"e7b579db7777471cb86ab9e39d96426f\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_e7b579db7777471cb86ab9e39d96426f = echarts.init(\n",
       "                    document.getElementById('e7b579db7777471cb86ab9e39d96426f'), 'white', {renderer: 'canvas'});\n",
       "                var option_e7b579db7777471cb86ab9e39d96426f = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"graph\",\n",
       "            \"layout\": \"force\",\n",
       "            \"symbolSize\": 10,\n",
       "            \"circular\": {\n",
       "                \"rotateLabel\": false\n",
       "            },\n",
       "            \"force\": {\n",
       "                \"repulsion\": 5000,\n",
       "                \"edgeLength\": 50,\n",
       "                \"gravity\": 0.2\n",
       "            },\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"show\": true,\n",
       "                \"width\": 1,\n",
       "                \"opacity\": 1,\n",
       "                \"curveness\": 0,\n",
       "                \"type\": \"solid\"\n",
       "            },\n",
       "            \"roam\": true,\n",
       "            \"draggable\": false,\n",
       "            \"focusNodeAdjacency\": true,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"Huskies_D1\",\n",
       "                    \"symbolSize\": 10\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Huskies_D2\",\n",
       "                    \"symbolSize\": 10\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Huskies_D3\",\n",
       "                    \"symbolSize\": 10\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Huskies_D4\",\n",
       "                    \"symbolSize\": 10\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Huskies_D5\",\n",
       "                    \"symbolSize\": 10\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Huskies_F1\",\n",
       "                    \"symbolSize\": 10\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Huskies_F2\",\n",
       "                    \"symbolSize\": 10\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Huskies_F3\",\n",
       "                    \"symbolSize\": 10\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Huskies_G1\",\n",
       "                    \"symbolSize\": 10\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Huskies_M1\",\n",
       "                    \"symbolSize\": 10\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Huskies_M2\",\n",
       "                    \"symbolSize\": 10\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Huskies_M3\",\n",
       "                    \"symbolSize\": 10\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Huskies_M4\",\n",
       "                    \"symbolSize\": 10\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Huskies_M5\",\n",
       "                    \"symbolSize\": 10\n",
       "                }\n",
       "            ],\n",
       "            \"edgeLabel\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"middle\",\n",
       "                \"margin\": 8,\n",
       "                \"formatter\": \"{c}\"\n",
       "            },\n",
       "            \"edgeSymbol\": [\n",
       "                null,\n",
       "                null\n",
       "            ],\n",
       "            \"edgeSymbolSize\": 10,\n",
       "            \"links\": [\n",
       "                {\n",
       "                    \"source\": \"Huskies_D1\",\n",
       "                    \"target\": \"Huskies_D2\",\n",
       "                    \"value\": 14\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D1\",\n",
       "                    \"target\": \"Huskies_D3\",\n",
       "                    \"value\": 8\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D1\",\n",
       "                    \"target\": \"Huskies_D4\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D1\",\n",
       "                    \"target\": \"Huskies_D5\",\n",
       "                    \"value\": 3\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D1\",\n",
       "                    \"target\": \"Huskies_F1\",\n",
       "                    \"value\": 3\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D1\",\n",
       "                    \"target\": \"Huskies_F2\",\n",
       "                    \"value\": 3\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D1\",\n",
       "                    \"target\": \"Huskies_F3\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D1\",\n",
       "                    \"target\": \"Huskies_G1\",\n",
       "                    \"value\": 2\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D1\",\n",
       "                    \"target\": \"Huskies_M1\",\n",
       "                    \"value\": 11\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D1\",\n",
       "                    \"target\": \"Huskies_M2\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D1\",\n",
       "                    \"target\": \"Huskies_M3\",\n",
       "                    \"value\": 4\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D1\",\n",
       "                    \"target\": \"Huskies_M4\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D2\",\n",
       "                    \"target\": \"Huskies_D1\",\n",
       "                    \"value\": 11\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D2\",\n",
       "                    \"target\": \"Huskies_D3\",\n",
       "                    \"value\": 18\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D2\",\n",
       "                    \"target\": \"Huskies_F1\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D2\",\n",
       "                    \"target\": \"Huskies_F2\",\n",
       "                    \"value\": 3\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D2\",\n",
       "                    \"target\": \"Huskies_G1\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D2\",\n",
       "                    \"target\": \"Huskies_M1\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D2\",\n",
       "                    \"target\": \"Huskies_M3\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D3\",\n",
       "                    \"target\": \"Huskies_D1\",\n",
       "                    \"value\": 6\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D3\",\n",
       "                    \"target\": \"Huskies_D2\",\n",
       "                    \"value\": 6\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D3\",\n",
       "                    \"target\": \"Huskies_D4\",\n",
       "                    \"value\": 9\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D3\",\n",
       "                    \"target\": \"Huskies_F1\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D3\",\n",
       "                    \"target\": \"Huskies_F2\",\n",
       "                    \"value\": 2\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D3\",\n",
       "                    \"target\": \"Huskies_F3\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D3\",\n",
       "                    \"target\": \"Huskies_G1\",\n",
       "                    \"value\": 6\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D3\",\n",
       "                    \"target\": \"Huskies_M1\",\n",
       "                    \"value\": 4\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D3\",\n",
       "                    \"target\": \"Huskies_M2\",\n",
       "                    \"value\": 5\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D3\",\n",
       "                    \"target\": \"Huskies_M3\",\n",
       "                    \"value\": 6\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D3\",\n",
       "                    \"target\": \"Huskies_M4\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D3\",\n",
       "                    \"target\": \"Huskies_M5\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D4\",\n",
       "                    \"target\": \"Huskies_D2\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D4\",\n",
       "                    \"target\": \"Huskies_D3\",\n",
       "                    \"value\": 4\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D4\",\n",
       "                    \"target\": \"Huskies_F1\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D4\",\n",
       "                    \"target\": \"Huskies_F2\",\n",
       "                    \"value\": 2\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D4\",\n",
       "                    \"target\": \"Huskies_F3\",\n",
       "                    \"value\": 2\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D4\",\n",
       "                    \"target\": \"Huskies_M1\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D4\",\n",
       "                    \"target\": \"Huskies_M2\",\n",
       "                    \"value\": 3\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D4\",\n",
       "                    \"target\": \"Huskies_M3\",\n",
       "                    \"value\": 2\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D4\",\n",
       "                    \"target\": \"Huskies_M4\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D5\",\n",
       "                    \"target\": \"Huskies_D1\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D5\",\n",
       "                    \"target\": \"Huskies_D5\",\n",
       "                    \"value\": 2\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D5\",\n",
       "                    \"target\": \"Huskies_F1\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D5\",\n",
       "                    \"target\": \"Huskies_F2\",\n",
       "                    \"value\": 8\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D5\",\n",
       "                    \"target\": \"Huskies_M1\",\n",
       "                    \"value\": 4\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_D5\",\n",
       "                    \"target\": \"Huskies_M3\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_F1\",\n",
       "                    \"target\": \"Huskies_D1\",\n",
       "                    \"value\": 2\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_F1\",\n",
       "                    \"target\": \"Huskies_D5\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_F1\",\n",
       "                    \"target\": \"Huskies_F2\",\n",
       "                    \"value\": 5\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_F1\",\n",
       "                    \"target\": \"Huskies_F3\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_F1\",\n",
       "                    \"target\": \"Huskies_M1\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_F1\",\n",
       "                    \"target\": \"Huskies_M5\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_F2\",\n",
       "                    \"target\": \"Huskies_D1\",\n",
       "                    \"value\": 3\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_F2\",\n",
       "                    \"target\": \"Huskies_D3\",\n",
       "                    \"value\": 4\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_F2\",\n",
       "                    \"target\": \"Huskies_D4\",\n",
       "                    \"value\": 2\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_F2\",\n",
       "                    \"target\": \"Huskies_D5\",\n",
       "                    \"value\": 4\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_F2\",\n",
       "                    \"target\": \"Huskies_F1\",\n",
       "                    \"value\": 3\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_F2\",\n",
       "                    \"target\": \"Huskies_F3\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_F2\",\n",
       "                    \"target\": \"Huskies_M1\",\n",
       "                    \"value\": 14\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_F2\",\n",
       "                    \"target\": \"Huskies_M3\",\n",
       "                    \"value\": 4\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_F2\",\n",
       "                    \"target\": \"Huskies_M4\",\n",
       "                    \"value\": 2\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_F2\",\n",
       "                    \"target\": \"Huskies_M5\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_F3\",\n",
       "                    \"target\": \"Huskies_D2\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_F3\",\n",
       "                    \"target\": \"Huskies_D3\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_F3\",\n",
       "                    \"target\": \"Huskies_F1\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_F3\",\n",
       "                    \"target\": \"Huskies_F2\",\n",
       "                    \"value\": 3\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_F3\",\n",
       "                    \"target\": \"Huskies_M2\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_F3\",\n",
       "                    \"target\": \"Huskies_M3\",\n",
       "                    \"value\": 2\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_G1\",\n",
       "                    \"target\": \"Huskies_D1\",\n",
       "                    \"value\": 2\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_G1\",\n",
       "                    \"target\": \"Huskies_D3\",\n",
       "                    \"value\": 2\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_G1\",\n",
       "                    \"target\": \"Huskies_D5\",\n",
       "                    \"value\": 2\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_G1\",\n",
       "                    \"target\": \"Huskies_F1\",\n",
       "                    \"value\": 2\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_G1\",\n",
       "                    \"target\": \"Huskies_G1\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_G1\",\n",
       "                    \"target\": \"Huskies_M1\",\n",
       "                    \"value\": 3\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M1\",\n",
       "                    \"target\": \"Huskies_D1\",\n",
       "                    \"value\": 13\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M1\",\n",
       "                    \"target\": \"Huskies_D2\",\n",
       "                    \"value\": 3\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M1\",\n",
       "                    \"target\": \"Huskies_D4\",\n",
       "                    \"value\": 3\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M1\",\n",
       "                    \"target\": \"Huskies_D5\",\n",
       "                    \"value\": 2\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M1\",\n",
       "                    \"target\": \"Huskies_F1\",\n",
       "                    \"value\": 5\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M1\",\n",
       "                    \"target\": \"Huskies_F2\",\n",
       "                    \"value\": 10\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M1\",\n",
       "                    \"target\": \"Huskies_F3\",\n",
       "                    \"value\": 2\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M1\",\n",
       "                    \"target\": \"Huskies_G1\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M1\",\n",
       "                    \"target\": \"Huskies_M1\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M1\",\n",
       "                    \"target\": \"Huskies_M2\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M1\",\n",
       "                    \"target\": \"Huskies_M3\",\n",
       "                    \"value\": 8\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M1\",\n",
       "                    \"target\": \"Huskies_M4\",\n",
       "                    \"value\": 2\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M1\",\n",
       "                    \"target\": \"Huskies_M5\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M2\",\n",
       "                    \"target\": \"Huskies_D2\",\n",
       "                    \"value\": 2\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M2\",\n",
       "                    \"target\": \"Huskies_D3\",\n",
       "                    \"value\": 2\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M2\",\n",
       "                    \"target\": \"Huskies_D4\",\n",
       "                    \"value\": 4\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M2\",\n",
       "                    \"target\": \"Huskies_F1\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M2\",\n",
       "                    \"target\": \"Huskies_F3\",\n",
       "                    \"value\": 2\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M2\",\n",
       "                    \"target\": \"Huskies_G1\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M2\",\n",
       "                    \"target\": \"Huskies_M1\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M2\",\n",
       "                    \"target\": \"Huskies_M3\",\n",
       "                    \"value\": 7\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M3\",\n",
       "                    \"target\": \"Huskies_D1\",\n",
       "                    \"value\": 6\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M3\",\n",
       "                    \"target\": \"Huskies_D2\",\n",
       "                    \"value\": 3\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M3\",\n",
       "                    \"target\": \"Huskies_D3\",\n",
       "                    \"value\": 8\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M3\",\n",
       "                    \"target\": \"Huskies_D4\",\n",
       "                    \"value\": 2\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M3\",\n",
       "                    \"target\": \"Huskies_D5\",\n",
       "                    \"value\": 6\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M3\",\n",
       "                    \"target\": \"Huskies_F2\",\n",
       "                    \"value\": 6\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M3\",\n",
       "                    \"target\": \"Huskies_F3\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M3\",\n",
       "                    \"target\": \"Huskies_M1\",\n",
       "                    \"value\": 9\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M3\",\n",
       "                    \"target\": \"Huskies_M2\",\n",
       "                    \"value\": 4\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M4\",\n",
       "                    \"target\": \"Huskies_D4\",\n",
       "                    \"value\": 2\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M4\",\n",
       "                    \"target\": \"Huskies_F2\",\n",
       "                    \"value\": 2\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M4\",\n",
       "                    \"target\": \"Huskies_F3\",\n",
       "                    \"value\": 2\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M4\",\n",
       "                    \"target\": \"Huskies_M1\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M4\",\n",
       "                    \"target\": \"Huskies_M3\",\n",
       "                    \"value\": 2\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M5\",\n",
       "                    \"target\": \"Huskies_F2\",\n",
       "                    \"value\": 2\n",
       "                },\n",
       "                {\n",
       "                    \"source\": \"Huskies_M5\",\n",
       "                    \"target\": \"Huskies_M4\",\n",
       "                    \"value\": 1\n",
       "                }\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [],\n",
       "            \"selected\": {},\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u4f20\\u7403\\u7f51\\u7edc\\u56fe\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_e7b579db7777471cb86ab9e39d96426f.setOption(option_e7b579db7777471cb86ab9e39d96426f);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x263eac08108>"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "graph.render_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
